From fb2080f90e6a904ffca312ed117856074def7bbf Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 24 Sep 2004 16:23:11 +0000 Subject: [PATCH] If we don't have a waypoint name, create one. --- waypt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/waypt.c b/waypt.c index 9b5aa9c05..fde54f87b 100644 --- a/waypt.c +++ b/waypt.c @@ -74,21 +74,27 @@ void waypt_add(waypoint *wpt) { ENQUEUE_TAIL(&waypt_head, &wpt->Q); + waypt_ct++; /* * Some input may not have one or more of these types so we * try to be sure that we have these fields even if just by * copying them from elsewhere. */ + if (wpt->shortname == NULL) { if (wpt->description) { wpt->shortname = xstrdup(wpt->description); + } else if (wpt->notes) { + wpt->shortname = xstrdup(wpt->notes); } else { - if (wpt->notes) { - wpt->shortname = xstrdup(wpt->notes); - } + /* Last ditch: make up a name */ + char cbuf[10]; + snprintf(cbuf, sizeof(cbuf), "WPT%03d", waypt_ct); + wpt->shortname = xstrdup(cbuf); } } + if (wpt->description == NULL || strlen(wpt->description) == 0) { if (wpt->description) xfree(wpt->description); @@ -100,7 +106,6 @@ waypt_add(waypoint *wpt) } } } - waypt_ct++; } void -- 2.30.2